home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 12 - 1996 / 12.07 Jul 96 / Javascript < prev   
Encoding:
Text File  |  1996-06-14  |  2.9 KB  |  86 lines  |  [TEXT/R*ch]

  1.  
  2. <HEAD>
  3. <SCRIPT LANGUAGE="JavaScript">
  4. <!--- these comments should hide the script from old browsers
  5. function checkNum(str, min, max) {
  6.     if (str == "") {
  7.         alert("Enter a number in the field, please.")
  8.         return false
  9.     }
  10.     for (var i = 0; i < str.length; i++) {
  11.         var ch = str.substring(i, i + 1)
  12.         if (ch < "0" || ch > "9") {
  13.             alert("Enter a number, please.")
  14.             return false
  15.         }
  16.     }
  17.  
  18.     var val = parseInt(str, 10)
  19.     if ((val < min) || (val > max)) {
  20.         alert("Try a number from 1 to 10.")
  21.         return false
  22.     }
  23.     return true
  24. }
  25.  
  26. function thanks() {
  27.     alert("Thank you.")
  28. }
  29. // end hiding from old browsers -->
  30. </SCRIPT>
  31. </HEAD>
  32.  
  33. <BODY>
  34. <FORM NAME="ex5">
  35. Please enter a number from 1 to 10:
  36. <INPUT NAME="num"
  37.     onChange="if (!checkNum(this.value, 1, 10))
  38.         {this.focus();this.select();} else {thanks()}">
  39. </FORM>
  40. </BODY>
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60. http://www.homepages.com/fun/1040EZ.html
  61. http://www.iohk.com/UserPages/acheng/javascript.html
  62. http://www.superprism.net/doc/EXPRESS/util/currency.html
  63. http://www.wrldpwr.com/javascriptzen.html
  64.  
  65. The color picker shows how JavaScript can work with frames and color: pass the mouse over the name of a color in one frame and the background of another frame will become that color.  Other examples are downright inspirational, such as the JavaScript VRML clock, which uses JavaScript to display a three-dimensional clock if you have a VRML browser.
  66.  
  67. http://www.lsi.usp.br/doc/color/picker.html
  68. http://www.phoenix.net/~jalonso/applets/vrml
  69.  
  70. Many more example applications are available at http://www.gamelan.com/.
  71. Remember how interesting (and sometimes annoyingly funky) Web pages became when authors started using and abusing sundry new tools like backgrounds and frames?  Expect to see another round of enlightening and obscure Web sites as developers and hackers begin to understand and use JavaScript.
  72. For More Information
  73. A growing number of information sources about JavaScript are online.  Andy Augustine’s JavaScript FAQ is at:
  74.  
  75. http://www.freqgrafx.com/411/jsfaq.html
  76. There is also a JavaScript mailing list, a high-volume, sometimes technical list for discussion about using the language.  To subscribe, send a message to majordomo@obscure.org with a message body of “subscribe javascript”.  A digest version of the list is also available.  To subscribe, use a message body of “subscribe javascript-digest”.  Further discussion takes place on the newsgroup comp.lang.javascript.
  77. Netscape’s official JavaScript documentation is required reading if you plan to learn your way around JavaScript.  The files are also downloadable for reading offline.
  78.  
  79. http://home.netscape.com/eng/mozilla/2.0/handbook/javascript/index.html
  80. http://home.netscape.com/eng/mozilla/2.0/handbook/javascript/jsdoc.zip
  81.  
  82. Augustine maintains a list of online tutorials, example applications and other information at JavaScript 411.  Finally, the ubiquitous Yahoo naturally has an index of JavaScript-related goodies.
  83.  
  84. http://www.freqgrafx.com/411/
  85. http://www.yahoo.com/Computers_and_Internet/Languages/JavaScript/
  86.